FROM ubuntu

RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
RUN apt update
RUN apt upgrade -y
RUN apt install git -y
RUN rm -f /etc/localtime && ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && apt install nginx -y
RUN apt install lrzsz -y
RUN apt install build-essential -y
RUN apt install libtool -y
RUN apt install libpcre3 libpcre3-dev -y
RUN apt install zlib1g-dev -y
RUN apt install openssl -y
RUN apt install python3 -y
RUN apt install python3-pip -y
RUN pip3 config set global.index-url https://mirrors.ustc.edu.cn/pypi/web/simple
RUN pip3 install virtualenv
RUN pip3 install uwsgi
RUN mkdir /home/CampusQ
RUN cd /home/CampusQ && virtualenv -p /usr/bin/python3 env
RUN cd /home/CampusQ && bash -c "source env/bin/activate" && pip3 install uwsgi
RUN cd /home/CampusQ && bash -c "source env/bin/activate" && git clone https://gitee.com/jingxiua/xyxw.git
RUN cd /home/CampusQ && bash -c "source env/bin/activate" && pip3 install -r xyxw/requirement.txt
RUN cd /home/CampusQ && bash -c "source env/bin/activate" && echo "yes" > python3 xyxw/manage.py collectstatic
RUN mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
RUN cp /home/CampusQ/xyxw/CampusQ.conf /etc/nginx/nginx.conf

EXPOSE 80

CMD ["bash","/home/CampusQ/xyxw/start.sh"]
